import { createApp } from 'vue'
import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import App from '../App'

const store = createStore({
    state() {
        return {
            imgurl: '',
            history: [],
            button: 1,
            size: 200,
            // name: '芯云二维码'

        }
    },
    mutations: {
        geturl(state, mu) {
            state.imgurl = mu;
        },
        additem(state, item) {
            state.history.push(item);
        },
        changebut(state, but) {
            state.button = but;
        }
    },
    actions: {},
    modules: {},
    plugins: [createPersistedState({
        storage: window.localStorage,
        reducer(val) {
            return {
                // 只保存module user内部所有变量持久化
                history: val.history
            }
        }
    })],
})

const app = createApp({ App })

// 将 store 实例作为插件安装
app.use(store)
export default store